// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import vconsole from 'vconsole'

import 'lib-flexible'
import MintUI,{Toast} from 'mint-ui'
import './assets/mint-ui/mintui.scss'
import '@/services/axiosDriver/index'
import axios from 'axios'
import appCom from '@/components'
Vue.use(MintUI)
Vue.use(appCom)

Vue.config.productionTip = false

/* eslint-disable no-new */
router.beforeEach(async (to, from, next) => {

  let token = localStorage.getItem('token')

  const passPaths = new Set(['/login', '/handValidate'])

  if(!token){
    if( passPaths.has(to.path) ){
      next()
    }
    else{
      Toast('请重新登陆')
      next('/login')
    }
  }
  else{
    next()
  }
 /* let uid=localStorage.getItem('USERID')
  await checkToken().then(res=>{

  })
  if(!localStorage.getItem('sharetoken')){
    await postUsrtoToken(uid).then(res=>{
      localStorage.setItem('sharetoken',res)
    })
  }
  next();*/
})

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

new vconsole()
